package c.a.a.z.b;

import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.RadialGradient;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import b.f.e;
import c.a.a.b0.k.c;
import c.a.a.b0.k.f;
import c.a.a.b0.l.b;
import c.a.a.l;
import c.a.a.q;
import c.a.a.z.c.a;
import c.a.a.z.c.p;

/* compiled from: GradientStrokeContent */
public class i extends a {
    public final String o;
    public final boolean p;
    public final e<LinearGradient> q = new e(10);
    public final e<RadialGradient> r = new e(10);
    public final RectF s = new RectF();
    public final f t;
    public final int u;
    public final a<c, c> v;
    public final a<PointF, PointF> w;
    public final a<PointF, PointF> x;
    public p y;

    public i(l lVar, b bVar, c.a.a.b0.k.e eVar) {
        super(lVar, bVar, eVar.h.a(), eVar.i.a(), eVar.j, eVar.d, eVar.g, eVar.k, eVar.l);
        this.o = eVar.a;
        this.t = eVar.b;
        this.p = eVar.m;
        this.u = (int) (lVar.b.b() / 32.0f);
        a a = eVar.c.a();
        this.v = a;
        a.a.add(this);
        bVar.e(a);
        a = eVar.e.a();
        this.w = a;
        a.a.add(this);
        bVar.e(a);
        a = eVar.f.a();
        this.x = a;
        a.a.add(this);
        bVar.e(a);
    }

    public String a() {
        return this.o;
    }

    public final int[] e(int[] iArr) {
        p pVar = this.y;
        if (pVar != null) {
            Integer[] numArr = (Integer[]) pVar.e();
            int i = 0;
            if (iArr.length == numArr.length) {
                while (i < iArr.length) {
                    iArr[i] = numArr[i].intValue();
                    i++;
                }
            } else {
                iArr = new int[numArr.length];
                while (i < numArr.length) {
                    iArr[i] = numArr[i].intValue();
                    i++;
                }
            }
        }
        return iArr;
    }

    public void g(Canvas canvas, Matrix matrix, int i) {
        Matrix matrix2 = matrix;
        if (!this.p) {
            Shader shader;
            b(this.s, matrix2, false);
            long j;
            PointF pointF;
            PointF pointF2;
            c cVar;
            Shader linearGradient;
            if (this.t == f.LINEAR) {
                j = (long) j();
                shader = (LinearGradient) this.q.e(j);
                if (shader == null) {
                    pointF = (PointF) this.w.e();
                    pointF2 = (PointF) this.x.e();
                    cVar = (c) this.v.e();
                    linearGradient = new LinearGradient(pointF.x, pointF.y, pointF2.x, pointF2.y, e(cVar.b), cVar.a, TileMode.CLAMP);
                    this.q.h(j, linearGradient);
                }
            } else {
                j = (long) j();
                shader = (RadialGradient) this.r.e(j);
                if (shader == null) {
                    pointF = (PointF) this.w.e();
                    pointF2 = (PointF) this.x.e();
                    cVar = (c) this.v.e();
                    int[] e = e(cVar.b);
                    float[] fArr = cVar.a;
                    float f = pointF.x;
                    float f2 = pointF.y;
                    linearGradient = new RadialGradient(f, f2, (float) Math.hypot((double) (pointF2.x - f), (double) (pointF2.y - f2)), e, fArr, TileMode.CLAMP);
                    this.r.h(j, linearGradient);
                }
            }
            shader.setLocalMatrix(matrix2);
            this.i.setShader(shader);
            super.g(canvas, matrix, i);
        }
    }

    public <T> void i(T t, c.a.a.f0.c<T> cVar) {
        super.i(t, cVar);
        if (t == q.D) {
            p pVar = this.y;
            if (pVar != null) {
                this.f.u.remove(pVar);
            }
            if (cVar == null) {
                this.y = null;
                return;
            }
            p pVar2 = new p(cVar, null);
            this.y = pVar2;
            pVar2.a.add(this);
            this.f.e(this.y);
        }
    }

    public final int j() {
        int round = Math.round(this.w.d * ((float) this.u));
        int round2 = Math.round(this.x.d * ((float) this.u));
        int round3 = Math.round(this.v.d * ((float) this.u));
        int i = 17;
        if (round != 0) {
            i = 527 * round;
        }
        if (round2 != 0) {
            i = (i * 31) * round2;
        }
        return round3 != 0 ? (i * 31) * round3 : i;
    }
}
